package org.wendu.wdoa.apprev.dao;

import org.apache.ibatis.annotations.*;
import org.wendu.wdoa.apprev.dto.leaveAddDto;
import org.wendu.wdoa.apprev.dto.leavequeryDto;
import org.wendu.wdoa.apprev.model.leave;
import org.wendu.wdoa.common.page.PageParam;

import java.util.List;
@Mapper
public interface ApprevDao {

    List<leave> findCurrentLeaveList(@Param("userId") String userId, @Param("pageParam") PageParam pageParam);

    @Select("select ifnull(max(convert(l_id,unsigned)),0)+1 from t_leave")
    Integer findNewId();

    @Insert("insert into t_leave(l_id,e_id,l_date,l_start,l_end,l_cause,l_status) values(#{leaveAdd.l_id},#{userId},#{leaveAdd.l_date},#{leaveAdd.l_start},#{leaveAdd.l_end},#{leaveAdd.l_cause},#{leaveAdd.l_status})")
    void addNewLeave(@Param("userId") String userId, @Param("leaveAdd") leaveAddDto leaveAdd);

    @Update("update t_leave set l_cause=#{l_cause},l_start=#{l_start},l_end=#{l_end},l_status=#{l_status} where l_id=#{l_id}")
    void updateLeave(leave leave);
    @Update("update t_leave set l_back=#{l_back},l_status=#{l_status} where l_id=#{l_id}")
    void endLeave(leave leave);
}
